package com.gurumades.jsonform.server.forms.dispatch;

import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.node.ObjectNode;

public class FieldsValuesExtractor {

	public static String valueForTextField(JsonNode node){
		try{
			return node.get("value").get("value").getTextValue();
		}catch(Exception e){
			return null;
		}
	}
	
	public static ObjectNode valueForImageField(JsonNode node){
		try{
			if (node.get("value").isObject()) {
				return (ObjectNode) node.get("value");
			}
			return null;
		}catch(Exception e){
			return null;
		}
	}

	public static boolean valueForBoolField(JsonNode jsonNode) {
		try{
			return jsonNode.get("value").get("value").getBooleanValue();
		}catch(Exception e){
			return false;
		}
	}
}
